﻿package  {
	import flash.display.MovieClip;
	import flash.events.Event;
	
	public class Main extends MovieClip{
		private var currentLevel:int = 0;
		
		public function Main() {
			addEventListener(Event.ADDED_TO_STAGE, onAdded);
		}
		
		private function onAdded(e:Event):void{
			removeEventListener(Event.ADDED_TO_STAGE, onAdded);
		}
		
		public function startGame():void{
			loadNextLevel();
		}
		
		public function loadNextLevel(pass = true){
			if (pass)
				currentLevel++;
				
			var newLevel:MovieClip;
			
			switch(currentLevel){
				case 1:
					newLevel = new Level1();
					break;
				case 2:
					newLevel = new Level2();
					break;
				case 3:
					newLevel = new Level3();
					break;
				case 4:
					newLevel = new Level4();
					break;
				case 5:
					newLevel = new Level5();
					break;
				case 6:
					newLevel = new Level6();
					break;
				case 7:
					newLevel = new Level7();
					break;
				case 8:
					newLevel = new Level8();
					break;
				case 9:
					newLevel = new Level9();
					break;
				case 10:
					newLevel = new Level10();
					break;
				case 11:
					showCredits();
					return;
					break;
			}
			
			addChild(newLevel);
		}
		
		private function showCredits():void{
			var credits:MovieClip = new Credits();
			credits.x = 400; credits.y = 300;
			addChild(credits);
		}

	}
	
}
